<?
class Forum{
     public function getCountReply($forum_id){
	    $sql = "select count(ans_id) as total from tb_forum_answer where forum_id = '$forum_id' ";
		$fetch = mysql_fetch_array(mysql_query($sql));
		return $fetch[total];
	 }
	 
	 public function getCountForum($cid){
	    $sql = "select count(forum_id) as total from tb_forum where forum_cate_id = '$cid' ";
		$fetch = mysql_fetch_array(mysql_query($sql));
		return $fetch[total];
	 }
	 
	 public function getCountReply_Cate($cid){
	    $sql = "select count(ans_id) as total 
		          from tb_forum_answer
		          where forum_id in(select forum_id from tb_forum where forum_cate_id = '$cid' ) ";
		$fetch = mysql_fetch_array(mysql_query($sql));
		return $fetch[total];
	 }
	 
	 public function who_online(){
	    $sql = "select distinct(m.user_id),u.user_usernm from tb_useronline_member m,tb_user u
		          where  m.user_id=u.user_id ";
	    $result = mysql_query($sql)or die(mysql_error());
		while($fetch = mysql_fetch_array($result)){
		   if($i++>0) $msg .= ",";
		   $msg .= $fetch[user_usernm];
		}
		return $msg;
	 }
	 

	 
	 public function replace_rudeword($text){
	     $sql = "select reset_rudeword from tb_web_reset where reset_id = '01' ";
		 $fetch = mysql_fetch_array(mysql_query($sql));
		 $e = explode(",",$fetch[0]);
		 foreach($e as $rude){
		     $text = str_replace("$rude","***",$text);
		 }
		 
		 return $text;
	 }
	 
	 public function getCount_DeleteForum(){
	    $sql_check1 = "select forum_id from tb_forum 
                     where  delete_warning = 'Y' 
													 ";
         $rows_check1 = mysql_num_rows(mysql_query($sql_check1));
		 return $rows_check1;
	 }	 
	 
	 public function getCount_DeleteAnswer(){
	    $sql_check1 = "select ans_id from tb_forum_answer
                     where delete_warning = 'Y' 
													 ";
         $rows_check1 = mysql_num_rows(mysql_query($sql_check1));
		 return $rows_check1;
	 }
}
?>
